/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>Project: javase - Set1
 * <p>Powered by webrx On 2021-12-09 10:20:38
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Set1 {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        set.add("java");

        set.addAll(List.of("java", "javascript", "html"));
        System.out.println(set);
        //set.clear();
        set.remove("java");
        System.out.println(set);
        set.add("java");
        //System.out.println(set);
        //set.removeAll(List.of("java", "javascript"));
        //System.out.println(set);
        System.out.println(set.size());
        //根据条件删除
        //set.removeIf(e -> e.startsWith("java"));
        System.out.println(set);

        System.out.println(set.contains("java"));
        //set.remove("java");
        System.out.println(set.containsAll(List.of("javascript", "java")));

        set.forEach(e -> {
            System.out.println(e);
        });

        set.forEach(System.out::println);

        for (String lan : set) {
            System.out.println(lan);
        }
    }
}
